﻿using DB.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace DB.EFData
{
	public class Context : DbContext
	{
		public DbSet<Member> Members { get; set; }
		public DbSet<Item> Items { get; set; }
		protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
		{
			optionsBuilder
				.UseLoggerFactory(logger)
				.UseSqlServer(connectionString: "Data Source=(localdb)\\MSSQLLocalDB; Initial Catalog=Demo");
		}

		public static readonly ILoggerFactory logger = LoggerFactory.Create( (iBuilder)=> {

			iBuilder.AddFilter( (string categoty,LogLevel level) =>
			{
				return categoty == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information;
			}).AddConsole();
		});
	}
}
